
const util = require('../../utils/util.js');
const urlMap1 = {
  "850283c46cab4c47a68367a22a01106e": '/page2/youer/index',//幼儿照护
  "b9d7078764620378bb7efd0b2d04841a": '/page2/yuer/index',//育儿管家
  "c9eb0c99ec3aaf907374e656b177f6f0": '/page2/ertongpeipanshi/index',//儿童成长陪伴
  "d6355dbcc3372d0c22d0370c6476f6a7": '/page2/jujiayanglao/index',//居家养老
  "366ea13b9bacdb9f5f8ebfd8d5aac945": '/page2/richangbaojie/index',//日常保洁
  "d3193ea8d82015c7845de72c0d0b4ec0": '/page2/rishibaojie/index',//日式保洁
  "3095908a7d87e73adf7596d84ed61666": '/page2/jiawuliaoli/index',//家务料理
  "5902f5f4599637b3cade1324cfdc227d": '/page2/muyinhuli/index',//母婴
  "3216d0ff246305345225d4a6c8f43c85": '/page2/jiayansichu/index',//家宴私厨
  "4b5b1f68d98fa5c371c035478d9cd3cb": '/page2/chongwuweiyang/index',//宠物喂养
  "9845a23ff6487322139da5281e53469c": '/page2/chongwuliuyang/index',//宠物遛养
  // "d6355dbcc3372d0c22d0370c6476f6a7": '/page2/chongwuxunyang/index',//宠物训养
  // "d6355dbcc3372d0c22d0370c6476f6a7": '/page2/chongwuyiliao/index',//宠物医疗
  "b4a4883e8df9bd71c13408950a267f09": '/page2/zhengqifuwu/index',//政企服务
  "eb058c97a129c6c90464ce4f6dc96ffb": '/page2/guanjiashouxi/index',//首席管家
  "842b679189c16f4c21b394e4888adf41": '/page2/guanjiajiawu/index',//家庭家务管家
  "3676662f07307dcc183b021953883d33": '/page2/guanjiajiaoyu/index',//家庭教育管家
  "09173eb0ff6ed462d9d9c2df44ef7efc": '/page2/guanjiaguoji/index',//国际教育管家
  "e5f2c4cc0784079dce7f2235c5e8005c": '/page2/xinjubaojie/index',//新居开荒
  "bd5933038935a66b7ca5e13803f6a4d0": '/page2/niandubaojie/index',//年度套餐
  // 整理收纳
  // "d707aa43d5eddafc4eb79bdba4ab9b93": '/page2/zhenglishouna/index',//
  "d707aa43d5eddafc4eb79bdba4ab9b93": '/page2/zlertong/index',//儿童整理收纳
  "8378929dc96179bb52065927a439971f": '/page2/zlyichu/index',//衣橱整理收纳
  "a390137b79e9162d33ddafc4096d822f": '/page2/zlketing/index',//客餐厅整理收纳
  "276f3787bef230b6a73f8ef2da06a0a5": '/page2/zlshufang/index',//书房整理收纳
  "cedcaa7750da4cbe0c5af5661812cc51": '/page2/zlrichang/index',//日常整理
  "d72919d9733f9d362454db29cfce6b13": '/page2/zlniandu/index',//年度陪伴式整理
  // 家具洗护
  "a03ca389dcca824a4402efe309273aea": '/page2/xihuchuanglian/index',//窗帘拆洗
  "fbcda938a98cd18d37ff5944afca8c7f": '/page2/xihuditan/index',//地毯洗护
  "0da7a239de46081f230c12104b62adbe": '/page2/xihushafa/index',//布艺沙发
  "25e1c17d8080c9f09ccd01e7e7c5fa59": '/page2/xihudiaodeng/index',//吊灯洗护
  "8697a52d437d6d2c6561cd0775ca50e3": '/page2/xihupiju/index',//皮具奢护
  //陪诊服务
  "9d8b6b2701a98654d80babad95577124": '/page2/peizhenfuwu/index',//陪诊服务
};
Page({
  /**
   * 页面的初始数据
   */
  data: {
    // name:'123',
    id: '',
    titleImage: '',
    desImage: '',
    detalsImages: [],
    imagesBaseUrl: util.imagesBaseUrl,
    // 
    name: '',
    description: '',
    tagsList: [],
    topimagesList: [],
    imagesList: [],
    bottomSwiperHeight: 240,
    flagZZ: false
  },
  getInit(id) {
    util.https('serviceDetailMgmt/serviceDetailQry', {
      "id": id,
    }, (res) => {
      console.log(res)
      let ss = res.serviceDetailBoList[0];
      let topimagesList = ss.topimages ? ss.topimages.split(',') : [],
        imagesList = ss.images ? ss.images.split(',') : [],
        tagsList = ss.tags ? ss.tags.split(',') : [];
      // this.getImgInfo(topimagesList[0]);
      this.setData({
        name: ss.name,
        description: ss.description,
        topimagesList: topimagesList,
        imagesList: imagesList,
        tagsList: tagsList
      })
    }, (res) => {
      console.log(res)
      wx.showModal({
        title: '温馨提示',
        content: res.errorMsg,
        confirmColor: '#F08302',
        showCancel: false,
        success(res) {
        }
      })
    })
  },
  doBack() {
    wx.navigateBack({
      delta: 1
    })
  },
  doNext() {
    let id = this.data.id;
    console.log(id)
    const url = urlMap1[id]
    if (url) {
      wx.navigateGo({ url: url })
    } else {
      console.log('无页面')
    }
  },
  getImgInfo(imageUrl) {
    const _this = this;
    wx.getImageInfo({
      src: imageUrl,
      success: function (res) {
        console.log('图片高度:', res);
        _this.setData({
          bottomSwiperHeight: res.height
        })
      },
      fail: function (err) {
        console.error('获取图片信息失败:', err);
      }
    });
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    console.log(options)
    if (options && options.id) {
      const data = options;
      const zzList = {
        "eb058c97a129c6c90464ce4f6dc96ffb": '/page2/guanjiashouxi/index',//首席管家
        "842b679189c16f4c21b394e4888adf41": '/page2/guanjiajiawu/index',//家庭家务管家
        "3676662f07307dcc183b021953883d33": '/page2/guanjiajiaoyu/index',//家庭教育管家
        "09173eb0ff6ed462d9d9c2df44ef7efc": '/page2/guanjiaguoji/index',//国际教育管家
      };
      if (zzList[data.id]) {
        this.setData({
          id: data.id,
          flagZZ: true
        })
      } else {
        this.setData({
          id: data.id,
          flagZZ: false
        })
      }
      this.getInit(data.id)

    }else{
      wx.showModal({
        title: '温馨提示',
        content: '非法参数访问！',
        confirmColor: '#F08302',
        showCancel: false,
        success(res) {
        }
      })
    }

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    wx.setStorageSync('address_get', '');
    // wx.getStorage({
    //   key: 'fenlei_yuyue',
    //   success: (res) => {
    //     console.log(res)
    //     let data = res.data;
    //     const zzList = {
    //       "eb058c97a129c6c90464ce4f6dc96ffb": '/page2/guanjiashouxi/index',//首席管家
    //       "842b679189c16f4c21b394e4888adf41": '/page2/guanjiajiawu/index',//家庭家务管家
    //       "3676662f07307dcc183b021953883d33": '/page2/guanjiajiaoyu/index',//家庭教育管家
    //       "09173eb0ff6ed462d9d9c2df44ef7efc": '/page2/guanjiaguoji/index',//国际教育管家
    //     };
    //     if (zzList[data.id]) {
    //       this.setData({
    //         id: data.id,
    //         flagZZ: true
    //       })
    //     } else {
    //       this.setData({
    //         id: data.id,
    //         flagZZ: false
    //       })
    //     }
    //     this.getInit(data.id)
    //   }
    // });

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  },

})